<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-detect-edit" th:object="${detect}">
        <input id="detectId" name="detectId" th:field="*{detectId}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">名称：</label>
            <div class="col-sm-8">
                <input id="name" name="name" th:field="*{name}" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态：</label>
            <div class="col-sm-8">
                <div class="onoffswitch">
                    <input type="checkbox" th:checked="${detect.state == 0 ? true : false}"
                           class="onoffswitch-checkbox" id="state" name="state">
                    <label class="onoffswitch-label" for="state">
                        <span class="onoffswitch-inner"></span>
                        <span class="onoffswitch-switch"></span>
                    </label>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">折扣：</label>
            <div class="col-sm-8">
                <input id="discount" name="discount" th:field="*{discount}" class="form-control" type="text">
            </div>
        </div>
    </form>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/detect"
    $("#form-detect-edit").validate({
        rules: {
            name: {
                required: true
            },
            discount: {
                required: true,
                range: [0, 1]
            },
        }
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-detect-edit').serialize());
        }
    }
</script>
</body>
</html>
